import request from "@/utils/http";
export interface ParamsData {
  phone: string;
  password: string;
}
interface TokenData {
  name: string;
  nickName: string;
  token: string;
  userId: number;
}
interface userInfoData {
  id:number;
  name:string;
  nickName: string;
}
interface registerParamsData {
  phone: string;
  password: string;
  code: string;
}
/**
 * @description 登录
 * @param params 登录所要的账号密码
 * @returns Promise
 */
export const reqLogin = (params: ParamsData) => {
  return request.post<any, TokenData>("/api/user/passport/login", params);
};

/**
 *
 * @returns 获取用户信息
 */
export const reqUserInfo = () => {
  return request.get<any,userInfoData>(`/api/user/passport/auth/getUserInfo`);
};

/**
 * @description 获取验证码
 * @param phone 手机号
 * @returns
 */
export const reqCode = (phone: string) => {
  return request.get<any, string>(`/api/user/passport/sendCode/${phone}`);
};
/**
 * @description 注册请求
 * @param params 注册
 * @returns 
 */
export const reqRegister = (params:registerParamsData) => {
  return request.post<any,null>("/api/user/passport/register", params);
};

/**
 * 
 * @returns 退出登录
 */
export const reqLogout=()=>{
  return request.get<any,null>('/api/user/passport/logout')
}
